﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ZiLaisgssjsz.aspx.cs" Inherits="Web.Pages.YongShui.JiChuXX.ZiLaisgssjsz" Theme="Default" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="../../../JS/AddEditCancel.js"></script>
    <script src="../../../JS/jquery.js"></script>
    <title></title>
    <script type="text/javascript">
        function ClearInfo() {
            txtMINGCHENG.SetText("");
            ddlGUANLIK.SetText("");
            ddlSUOSHUSF.SetText("");
            txtWENJIANMMGZ.SetText("");
        }

        function display(op) {
            if (gvList.GetFocusedRowIndex() == -1) {
                return;
            }
            if (op == "add") {
                hdCollection.Set("ID", -1);
                btnAdd.SetVisible(false);
                btnEdit.SetVisible(false);
                btnDel.SetVisible(false);
                btnSave.SetVisible(true);
                btnCancel.SetVisible(true);

                ClearInfo();
                txtMINGCHENG.SetEnabled(true);
                ddlGUANLIK.SetEnabled(true);
                ddlSUOSHUSF.SetEnabled(true);
                txtWENJIANMMGZ.SetEnabled(true);
                listCover(true, "divList");
                txtMINGCHENG.Focus();
            }
            else if (op == "edit") {
                hdCollection.Set("ID", gvList.GetRowKey(gvList.GetFocusedRowIndex()));
                btnAdd.SetVisible(false);
                btnEdit.SetVisible(false);
                btnDel.SetVisible(false);
                btnSave.SetVisible(true);
                btnCancel.SetVisible(true);

                txtMINGCHENG.SetEnabled(true);
                ddlGUANLIK.SetEnabled(true);
                ddlSUOSHUSF.SetEnabled(true);
                txtWENJIANMMGZ.SetEnabled(true);
                listCover(true, "divList");
                ASPxCallback1.PerformCallback("info");
            }
            else {
                txtMINGCHENG.SetEnabled(false);
                ddlGUANLIK.SetEnabled(false);
                ddlSUOSHUSF.SetEnabled(false);
                txtWENJIANMMGZ.SetEnabled(false);
                btnAdd.SetVisible(true);
                btnEdit.SetVisible(true);
                btnDel.SetVisible(true);
                btnSave.SetVisible(false);
                btnCancel.SetVisible(false);
                listCover(false, "divList");
                hdCollection.Set("ID", gvList.GetRowKey(gvList.GetFocusedRowIndex()));
                ASPxCallback1.PerformCallback("info");
            }
        }

        function del() {            
            if (confirm("确认删除吗？")) {
                hdCollection.Set("ID", gvList.GetRowKey(gvList.GetFocusedRowIndex()));
                ASPxCallback1.PerformCallback("del");
            }
            else {
                hdCollection.Set("ID", -1);
            }
        }

        function save() {
            if (txtMINGCHENG.GetText() == "") {
                alert("请输入名称！");
                txtMINGCHENG.Focus();
                return;
            }
            if (ddlGUANLIK.GetText() == "") {
                alert("请选择管理块！");
                ddlGUANLIK.Focus();
                return;
            }
            ASPxCallback1.PerformCallback("save");
        }

        function rowClick() {
            var id = -1;
            if (gvList.GetFocusedRowIndex() != -1) {
                id = gvList.GetRowKey(gvList.GetFocusedRowIndex());
                hdCollection.Set("ID", id);                
                ASPxCallback1.PerformCallback("info");
            }
            else {
                ClearInfo();
                hdCollection.Set("ID", id);
            }
        }

        function ASPxCallback1Complete(rs) {
            loadpanel1.Hide();
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            var specialIdentity = arr[2];
            var msg = arr[3].split('-');
            if (msg[0] == 'True') {
                alert(msg[1]);
            }
            hdCollection.Set("type", type);
            if (state == 'True') {
                if (type == "info") {
                    //加载信息
                    txtMINGCHENG.SetText(arr[4]);
                    ddlGUANLIK.SetValue(arr[5]);
                    ddlSUOSHUSF.SetValue(arr[6]);
                    txtWENJIANMMGZ.SetText(arr[7]);
                    txtMINGCHENG.Focus();
                }
                else if (type == "del") {
                    gvList.PerformCallback();
                }
                else if (type == "save") {
                    display("init", -1);
                    hdCollection.Set("OperateID", specialIdentity);
                    gvList.PerformCallback();
                }
            }
            else {

            }
        }
        function begincall() {
            loadpanel1.Show();
        }
        function endcall() {
            loadpanel1.Hide();
            //定位添加或修改的记录
            var oid = hdCollection.Get("OperateID");
            var index = -1;
            if (oid != -1 && typeof (oid) != undefined) {
                for (var i = 0; i < gvList.GetVisibleRowsOnPage() ; i++) {
                    if (gvList.GetRowKey(i) == oid) {
                        index = i;
                    }
                }
                if (index != -1) {
                    gvList.SetFocusedRowIndex(index);
                    gvList.MakeRowVisible(index);
                    hdCollection.Set("OperateID", -1);
                }
            }            
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            自来水公司数据设置
        </div>
        <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
        <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中"></dx:ASPxLoadingPanel>
        <table style="width: 100%">
            <tr>
                <td>
                    <asp:UpdatePanel runat="server" ID="updatePanel1">
                        <ContentTemplate>
                            <div style="width: 100%;">
                                <div id="divList" style="float: left; width: 55%;">
                                    <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1"
                                        Width="100%" OnCustomCallback="gvList_CustomCallback">
                                        <Columns>
                                            <dx:GridViewDataTextColumn FieldName="S_MINGCHENG" Caption="名称" Width="15%">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_GUANLIKBH" Caption="区号" Width="15%">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_GUANLIKMC" Caption="区名" Width="15%">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_SUOSHUSF" Caption="所属算法" Width="27%">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_WENJIANMMGZ" Caption="文件命名规则" Width="28%">
                                            </dx:GridViewDataTextColumn>
                                        </Columns>
                                        <SettingsBehavior AllowFocusedRow="True" ColumnResizeMode="Control"  ProcessFocusedRowChangedOnServer="false" />
                                        <Settings VerticalScrollableHeight="320" />
                                        <ClientSideEvents Init="function(s,e){AdjustSize(130,gvList);}"  FocusedRowChanged="function(s,e){rowClick();}" BeginCallback="function(s,e){begincall();}" EndCallback="function(s,e){endcall();}"/>
                                    </dx:ASPxGridView>
                                </div>
                                <div style="float: left; width: 2%;">&nbsp;</div>
                                <div style="float: left; width: 43%;">
                                    <table border="0" style="width: 100%" id="GridViewContentTable" runat="server">
                                        <tr>
                                            <td align="right" style="width: 30%">名称：
                                            </td>
                                            <td>
                                                <dx:ASPxTextBox ID="txtMINGCHENG" ClientInstanceName="txtMINGCHENG" ClientEnabled="false" runat="server" Width="100%" MaxLength="5">
                                                    <ClientSideEvents KeyPress="function(s,e){OnKeyNext(ddlGUANLIK);}"/>
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">所属区名：
                                            </td>
                                            <td>
                                                <dx:ASPxComboBox ID="ddlGUANLIK" ClientInstanceName="ddlGUANLIK" ClientEnabled="false" runat="server" ValueType="System.String">
                                                    <ClientSideEvents KeyPress="function(s,e){OnKeyNext(ddlSUOSHUSF);}"/>
                                                </dx:ASPxComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">所属算法：
                                            </td>
                                            <td>
                                                <dx:ASPxComboBox ID="ddlSUOSHUSF" ClientInstanceName="ddlSUOSHUSF" ClientEnabled="false" runat="server" ValueType="System.String">
                                                    <ClientSideEvents KeyPress="function(s,e){OnKeyNext(txtWENJIANMMGZ);}"/>
                                                </dx:ASPxComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">文件命名规则：
                                            </td>
                                            <td>
                                                <dx:ASPxTextBox ID="txtWENJIANMMGZ" ClientInstanceName="txtWENJIANMMGZ" ClientEnabled="false" runat="server" Width="100%">
                                                    <ClientSideEvents KeyPress="function(s,e){OnKeyNext(btnSave);}"/>
                                                </dx:ASPxTextBox>
                                            </td>
                                        </tr>
                                    </table>
                                    <div align="right">
                                        <hr />
                                        <dx:ASPxButton ID="btnAdd" ClientInstanceName="btnAdd" runat="server" Text="添加" AutoPostBack="false" ClientSideEvents-Click="function(s,e){display('add',-1)}" UseSubmitBehavior="false">
                                        </dx:ASPxButton>
                                        <dx:ASPxButton ID="btnEdit" ClientInstanceName="btnEdit" runat="server" Text="修改" AutoPostBack="false" UseSubmitBehavior="false">
                                            <ClientSideEvents Click="function(s,e){display('edit',-1);}"/>
                                        </dx:ASPxButton>
                                        <dx:ASPxButton ID="btnDel" ClientInstanceName="btnDel" runat="server" Text="删除" AutoPostBack="false" UseSubmitBehavior="false">
                                            <ClientSideEvents Click="function(s,e){del();}"/>
                                        </dx:ASPxButton>
                                        <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存"  AutoPostBack="false" ClientVisible="false" UseSubmitBehavior="false">
                                            <ClientSideEvents Click="function(s,e){save();}"/>
                                        </dx:ASPxButton>
                                        <dx:ASPxButton ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" ClientVisible="false" UseSubmitBehavior="false">
                                            <ClientSideEvents Click="function(s,e){display('init',-1);}"/>
                                        </dx:ASPxButton>
                                    </div>
                                </div>
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td>
                    <div>
                        说明事项：<br />
                        (1) 名称不允许相同
        <br />
                        (2) 文件命名规则：
        <br />
                        &nbsp;&nbsp;标志：不同类型的标志，只允许字母，长度小于3位。 空格，接【YYMM】代表年月。空格，接【.DBF】代表文件扩展名。
        <br />
                        &nbsp;&nbsp;以静安区为例：【JA&nbsp;YYYMM&nbsp;.DBF】
                    </div>
                </td>
            </tr>
        </table>

    </form>
</body>
</html>


